<?php
	session_start();
	$id_session = $_SESSION['id_session'];
    require_once "../setting/kon.php";
    require_once "../setting/library.php";
?>
<table class="table table-hover small">
    <!-- baris judul -->
    <thead>
      <tr>
        <th>Gambar</th>
        <th>Nama Barang</th>
        <th>Ukuran</th>
        <th>Warna</th>
        <th>Harga</th>
        <th width="15%">Kuantitas</th>
        <th width="15%">Subtotal</th>
        <th>Aksi</th>
      </tr>
    </thead>
    <!-- end baris judul -->
    <!-- baris isi produk dibeli -->
	<?php
		$sttmt = $koneksi->query("select o.id_temp,p.id_produk,p.nama_produk,p.gambar,p.harga,o.jumlah,u.id_ukuran,u.ukuran,o.diskon,p.slug from order_temp o inner join produk p on p.id_produk = o.id_produk left join ukuran u on u.id_ukuran = o.id_ukuran where o.id_session = '$id_session'");
		while($hasil = $sttmt->fetch(PDO::FETCH_ASSOC)){
	?>
		<tbody>
		  <tr>
			<td><img src="produk/<?php echo $hasil['gambar']?>" height="50"></td>
			<td><?php echo "<a href='produk-$hasil[slug]'><b>$hasil[nama_produk]</b></a>"; ?></td>
			<td>
				<?php
					if($hasil['id_ukuran'] == '1'){
						echo "-";
					}else{
						echo $hasil['ukuran'];
					}
				?>
			</td>
			<td><?php echo "Rp. ".harga($hasil['harga'])?></td>
			<td><?php echo $hasil['diskon']; ?></td>
			<td><?php echo $hasil['jumlah']; ?></td>
			<td>
				<?php 
					$sub_total = $hasil['jumlah'] * $hasil['harga'] - ($hasil['jumlah'] * $hasil['harga'] * $hasil['diskon']/100);
					echo "Rp. ".harga($sub_total);
				?>
			</td>
			<td>
			<?php echo "<a href='#' class='btn btn-danger btn-sm' onClick='delete_cart(".$hasil["id_temp"].")'><span class='glyphicon glyphicon-trash'></span></a>"; ?>
			</td>
		  </tr>
		</tbody>
	<?php
		$total = $total + $sub_total;
		}
	?>
    <!-- baris isi produk dibeli -->
    <!-- baris jumlah -->
    <thead>
      <tr>
        <th colspan="5"></th>
        <th>Jumlah</th>
        <th><?php echo "Rp. ".harga($total); ?></th>
        <th></th>
      </tr>
    </thead>
    <!-- end baris jumlah -->
  </table>